//! copyright © ecdata.cn 2021 - present
//! 应用范围逻辑处理
//! created by tyn 20250317

use crate::model::CustomerApp as CustomerAppModel;
use deck::{DataModel, DataTable, QueryValue, SelectExecutor, TableService};
use tube::{Value,Result};
use tube_web::RequestParameter;

/// 结构体的定义
pub struct CustomerApp {
    request: RequestParameter,
}

/// 基础数据操作实现
impl DataTable<CustomerAppModel> for CustomerApp {
    /// 指定数据源key
    fn datasource_key(&self) -> String {
        crate::DATASOURCE_KEY.to_owned()
    }
}

/// 基础业务操作服务实现
impl TableService<CustomerAppModel> for CustomerApp {
    /// 请求的数据信息
    fn value(&self) -> Value {
        self.request.value.clone()
    }

    /// 请求授权信息
    fn authorizer(&self) -> ((i8, u64, u64), (i8, u64), (i8, u64)) {
        self.request.get_auth_user()
    }
}

impl CustomerApp {
    /// 创建一个新的实例
    pub fn new(param: &RequestParameter) -> Self {
        CustomerApp {
            request: param.clone(),
        }
    }
}
